<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者，助力中小企业发展
// +----------------------------------------------------------------------
// | Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
// +----------------------------------------------------------------------
/**
 * Class Area
 * Desc  地区控制器
 * Create on 2024/5/13 9:06
 * Create by wangyafang
 */

namespace app\api\controller\wddj\user;


use app\common\controller\Api;

class Area extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\api\model\wddj\user\Area();
    }

    //省列表
    public function province()
    {
        if (!$this->request->isGet()) {
            $this->error('请求类型错误');
        }

        $data = $this->model
            ->where('level', 1)
            ->field('id,name,lng,lat')
            ->select();

        $this->success('请求成功', $data);
    }

    //市列表
    public function city()
    {
        if (!$this->request->isGet()) {
            $this->error('请求类型错误');
        }

        $province_id = $this->request->param('province_id');

        $data = $this->model
            ->where('level', 2)
            ->where('pid', $province_id)
            ->field('id,name,lng,lat')
            ->select();

        $this->success('请求成功', $data);
    }
}



 